#include <stdio.h>
#include <time.h>

unsigned short TIME;

void setHour(int h) {
    TIME = (TIME & 0x07FF) | (h << 11);
}

void setMinute(int m) {
    TIME = (TIME & 0xF81F) | (m << 5);
}

void setSecond(int s) {
    TIME = (TIME & 0xFFE0) | (s & 0x1F);
}

void setCurrentTime() {
    time_t now;
    struct tm *tm_info;

    time(&now);
    tm_info = localtime(&now);

    int hour = tm_info->tm_hour;
    int minute = tm_info->tm_min;
    int second = tm_info->tm_sec;

    setHour(hour);
    setMinute(minute);
    setSecond(second);
}

int main() {
    setCurrentTime();
    printf("TIME: 0x%04X\n", TIME);
    return 0;
}

